package Chapter2.Comparing.c9;

public class ThreadWindowOne extends Thread {
    private static int tickets=100;
    @Override
    public void run() {
        while (true) {
            if (tickets>0) {
                System.out.println(Thread.currentThread().getName()+"正在售票，票号："+tickets-- +".");
            }
            else {
                break;
            }
        }
    }

    public static void main(String[] args) {
        ThreadWindowOne one = new ThreadWindowOne();
        one.setName("1号");
        ThreadWindowOne two = new ThreadWindowOne();
        two.setName("2号");
        ThreadWindowOne three = new ThreadWindowOne();
        three.setName("3号");
        one.start();;
        two.start();
        three.start();
    }
}
